<template>
  <div class="bg">
    <router-link class="btn" :to="getLink"
      >即刻开始 <img class="go-img" src="/openapi/img/go.png" alt=""
    /></router-link>
  </div>
</template>
<script>
export default {
  data() {
    return {
      link: "",
    };
  },
  computed: {
    getLink() {
      const nav = this.$themeConfig.nav;
      if (nav && nav.length) {
        return this.getLinkFromNav(nav);
      } else {
        return this.$frontmatter.defaultActionLink;
      }
    },
  },
  methods: {
    getLinkFromNav(nav) {
      if (nav && nav.length) {
        nav.forEach((item) => {
          if (item.link && !this.link) {
            this.link = item.link;
            return this.link;
          } else if (!this.link) {
            this.getLinkFromNav(item.items);
          }
        });
      }
      return this.link;
    },
  },
};
</script>
<style scoped>
.bg {
  background-image: url(/openapi/img/bg.png);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-width: 1000px;
  z-index: -10;
  zoom: 1;
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  -webkit-background-size: cover;
  -o-background-size: cover;
  text-align: center;
}
.btn {
  display: block;
  width: 149px;
  height: 42px;
  background: #468be8;
  color: #fff;
  font-size: 16px;
  border-radius: 3px;
  text-align: center;
  line-height: 42px;
  position: absolute;
  top: 59.6%;
  left: 20%;
}
.go-img {
  vertical-align: middle;
}
@media (max-width: 375px) {
  .bg {
    min-width: 375px;
    background-image: url(/openapi/img/mbg.png);
  }
  .btn {
    display: inline-block;
    position: relative;
    left: 0;
  }
}
</style>